package xj.meta;

public class RootElementImpl 
  extends AbstractModelElement 
  implements RootElement {

  public RootElementImpl() {
  }

  public RootElementImpl(String name) {
    setName(name);
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
    setAttribute(ATTR_NAME, name);
  }

  @Override
  public Object clone() throws CloneNotSupportedException {
    RootElement ne = (RootElement) super.clone();
    ne.setName(name);
    return ne;
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o instanceof RootElement) {
      RootElement e = (RootElement) o;
      String ename = e.getName();
      if (name == null) {
	return (ename == null);
      } else {
	return name.equals(ename);
      }
    }
    return false;
  }

  @Override
  public int hashCode() {
    int c = 0;
    if (name != null) {
      c += name.hashCode();
    }
    return c;
  }

  protected String name;

  public static final String ATTR_NAME = "name";

}
